/*
逆序对是归并排序的应用
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 500010;
typedef long long LL;

int n;
int a[N];
int temp[N];

LL merge_sort(int l,int r){
	if(r-l<1) return 0;
	int mid=l+(r-l)/2;
	LL ans=merge_sort(l,mid);
	ans+= merge_sort(mid+1,r);
	
	int i=l,j=mid+1,k=0;//k用来控制temp数组 
	while(i<=mid&&j<=r){
		if(a[i]<=a[j]){
			temp[k++]=a[i++];
		}else{
			temp[k++]=a[j++];
			ans+=mid-i+1;
		}
	}
	
	while(i<=mid) temp[k++]=a[i++];
	while(j<=r) temp[k++]=a[j++];
	
	for(i=l,k=0;i<=r;){
		a[i++]=temp[k++];
	}
	return ans;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<merge_sort(0,n-1)<<endl;
	//for(int i=0;i<n;i++) cout<<a[i]<<" ";
	return 0;
}